<?php
class Shoppingcart_Models_Cart extends Tomato_Model_Entity
{
    protected $_properties = array(
        'id'                                => null,
        'cart_id'                           => null,
        'created_date'                      => null,
        'product_id'                        => null,
        'cart_quantity'                     => null,
        'product_attribute_value_id_chain'  => null,
        'cart_parent_id'                    => null,        
    );
    
    public function getImage($name = '_thumbnail', $size = '90', $isView = true){  
    	
    	$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
    	
    	$defaultImage = null;
    	if($isView){
	    	$lang = Zend_Controller_Front::getInstance()->getRequest()->getParam('lang');    	
	    	$getConfig 	  = Tomato_Config::getConfig();
	    	$noimage = 'noimage'.$size;
	    	$defaultImage = $viewRenderer->view->APP_STATIC_SERVER.'/'.$getConfig->value->products->$noimage->$lang;
    	}        
    	
    	$url = isset($this->_properties['product_image'])?$this->_properties['product_image']:null;
    	$arr  = explode(',',$this->_properties['product_image']);
		$file = $arr[0];
		$path = str_replace($viewRenderer->view->APP_STATIC_SERVER,getcwd(),$file);
		$file = Tomato_Helper_Helper::checkFile($path, $file, $name);
		$urlImage = $file?$file:$defaultImage;		
		
		return $urlImage;
    }
}